import { createApp } from 'vue';
import App from './App.vue';
import router from './router';
import store from './store';
import ElementPlus from 'element-plus';
import 'element-plus/dist/index.css';
import axios from 'axios';
import './assets/styles/global.css';

// axios配置
axios.defaults.baseURL = 'http://localhost:8080';

// 在应用启动时恢复用户状态
const savedUser = localStorage.getItem('user');
if (savedUser) {
  try {
    const user = JSON.parse(savedUser);
    store.commit('setCurrentUser', user);
  } catch (error) {
    console.error('解析用户数据失败:', error);
    localStorage.removeItem('user');
  }
}

// 创建应用实例
const app = createApp(App);
app.use(router);
app.use(store);
app.use(ElementPlus);
app.mount('#app');